<?php $this->load->view('header');?>

<body class="childrenBody">
	<!-- 视图 -->
	<div class="layui-form news_list">
		<form class="layui-form">
			<table class="layui-table" lay-even="" lay-skin="line">
			    <thead>
				<tr>
					<th>菜单名称</th>
					<th>背景图</th>
					<th>操作</th>
				</tr> 
			    </thead>
				<tbody class="goods_content" id="view"></tbody>
				
			</table>
			<div class="page_box" style="float: right;padding-right: 10px;">
				<div id="listpage"></div>
			</div>
		</form>
	</div>

	<!-- 模板 -->
	<script id="demo" type="text/html">
	    {{#  layui.each(d.list, function(index, item){ }}
			<tr>
			  <td>{{ item.title }}</td>
			  <td><img src="{{item.theme_img}}"></td>
			  <td>
			    <a class="layui-btn layui-btn-warm layui-btn-mini" id="edit{{ item.id }}" title="编辑">
			      <i class="layui-icon">&#xe642;</i>编辑
			    </a>
			  </td>
			</tr>
	    {{#  }); }}

	    {{#  if(d.list.length === 0){ }}
	      暂无数据
	    {{#  } }} 
	</script>

	<script type="text/javascript">
	layui.config({
		version: true
	}).use(['jquery','layer', 'laytpl', 'form', 'element', 'laypage'],function(){
		var layer = parent.layer === undefined ? layui.layer : parent.layer,
			laytpl = layui.laytpl,
			form = layui.form,
			element = layui.element,
			laypage = layui.laypage,
			$ = layui.jquery;

			$.get('admin.php/MemberMenu/get_list', function(data) 
			{
				var getTpl = demo.innerHTML;
				laytpl(getTpl).render(data, function(html){
				  $('#view').html(html);
				});


				layui.each(data.list, function(index, el) 
				{
					//编辑
					$('#edit'+el.id).click(function() 
					{
						var index = layui.layer.open({
							title : "编辑菜单",
							type : 2,
							content : "admin.php/MemberMenu/edit_menu/"+el.id,
							cancel: function(index, layero){ 
								location.reload();						 
							}  
						})

						//改变窗口大小时，重置弹窗的高度，防止超出可视区域
						$(window).resize(function(){
							layui.layer.full(index);
						})
						layui.layer.full(index);
					});


					form.render(); //更新全部
				});
			},'json');

	});
	</script>

</body>
</html>